﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Cole.Entities;
using Microsoft.Practices.EnterpriseLibrary.Data;

using System.Data;


namespace Cole.Repository
{
    public class AlumnoRepository:MasterRepository,IAlumnoRepository
    {
        public List<Alumno> GetAlumnoByApellidosNombresDNI(string criterio)
        {
            var query = _database.ExecuteSprocAccessor<Alumno>("GetAlumnoByApellidosNombresDNI", criterio);
            return query.ToList();
        }


        public void ModificarAlumno(Alumno alu)
        {


            var command = _database.GetStoredProcCommand("RegistrarAlumno");
            _database.AddInParameter(command, "Id", DbType.Int32, alu.Id);
            _database.AddInParameter(command, "apellidos", DbType.String, alu.apellidos);
            _database.AddInParameter(command, "nombres", DbType.String, alu.nombres);
            _database.AddInParameter(command, "fecha", DbType.Date, alu.fechaNacimiento);
            _database.AddInParameter(command, "nroDni", DbType.String, alu.nroDni);

            _database.ExecuteNonQuery(command);

            //MessageBox.Show("Se guardo Corectamente");
        }



        public void EliminarAlumno(int id)
        {
            var command = _database.GetStoredProcCommand("DeleteAlumno");

            _database.AddInParameter(command, "id", DbType.Int32, id);

            _database.ExecuteNonQuery(command);



        }
    }
}
